﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Chapter21.Models.SynchronizationSamples
{
    using System.Threading;

    public class SharedState
    {
        private int state = 0;
        private object syncBoot = new object();

        public SharedState()
        {

        }

        public int State
        {
            get { return state; }
            set { state = value; }
        }

        public int IncrementStateSyncBoot()
        {
            lock (syncBoot)
            {
                return ++state;
            }
        }
        public int IncrementStateInterlocked()
        {
            return Interlocked.Increment(ref state);
        }
    }
}
